package com.google.code.gronono.jarseeker.ui;

import java.util.List;

import javax.swing.table.AbstractTableModel;

import com.google.code.gronono.jarseeker.model.ClassFile;


public class ResultTableModel extends AbstractTableModel {
	/** serialVersionUID */
	private static final long serialVersionUID = 9102210696641188299L;

	private String firstColumnName;
	private String secondColumnName;
	private List<ClassFile> classFiles;
	
	public ResultTableModel(String firstColumnName, String secondColumnName, List<ClassFile> classFiles) {
		this.firstColumnName = firstColumnName;
		this.secondColumnName = secondColumnName;
		this.classFiles = classFiles;
	}
	
	public int getColumnCount() {
		return 2;
	}

	public int getRowCount() {
		return classFiles.size();
	}

	public Object getValueAt(int rowIndex, int columnIndex) {
		ClassFile classFile = classFiles.get(rowIndex);
		
		switch (columnIndex) {
		case 0:
			return classFile.getClassName();
		case 1:
			return classFile.getPath();
		default:
			throw new IndexOutOfBoundsException();
		}
	}

	@Override
	public String getColumnName(int column) {
		switch (column) {
		case 0:
			return firstColumnName;
		case 1:
			return secondColumnName;
		default:
			throw new IndexOutOfBoundsException();
		}
	}
}
